#include "cledMatrixAngle.h"
#include <stdio.h>
#include <math.h>

#define MATRIX_ANGLE_SIZE      42
static const uint32_t RotateMatrixAngle[MATRIX_ANGLE_SIZE][MATRIX_ANGLE_SIZE] = {
{0x0000, 0x20000, 0x40000, 0x60000, 0x80000, 0xA0000, 0xC0000, 0xE0000, 0x100000, 0x120000, 0x140000, 0x160000, 0x180000, 0x1A0000, 0x1C0000, 0x1E0000, 0x200000, 0x220000, 0x240000, 0x260000, 0x280000, 0x2A0000, 0x2C0000, 0x2E0000, 0x300000, 0x320000, 0x340000, 0x360000, 0x380000, 0x3A0000, 0x3C0000, 0x3E0000, 0x400000, 0x420000, 0x440000, 0x460000, 0x480000, 0x4A0000, 0x4C0000, 0x4E0000, 0x500000, 0x520000, },
{0x202CF, 0x20167, 0x400D4, 0x60093, 0x80070, 0xA005A, 0xC004B, 0xE0041, 0x100039, 0x120032, 0x14002D, 0x160029, 0x180026, 0x1A0023, 0x1C0020, 0x1E001E, 0x20001C, 0x22001A, 0x240019, 0x260018, 0x280016, 0x2A0015, 0x2C0014, 0x2E0013, 0x300013, 0x320012, 0x340011, 0x360010, 0x380010, 0x3A000F, 0x3C000F, 0x3E000E, 0x40000E, 0x42000D, 0x44000D, 0x46000D, 0x48000C, 0x4A000C, 0x4C000C, 0x4E000B, 0x50000B, 0x52000B, },
{0x402CF, 0x401FB, 0x50167, 0x7010D, 0x800D4, 0xA00AE, 0xC0093, 0xE007F, 0x100070, 0x120064, 0x14005A, 0x160052, 0x18004B, 0x1A0045, 0x1C0041, 0x1E003C, 0x200039, 0x220035, 0x240032, 0x260030, 0x28002D, 0x2A002B, 0x2C0029, 0x2E0027, 0x300026, 0x320024, 0x340023, 0x360021, 0x380020, 0x3A001F, 0x3C001E, 0x3E001D, 0x40001C, 0x42001B, 0x44001A, 0x46001A, 0x480019, 0x4A0018, 0x4C0018, 0x4E0017, 0x500016, 0x520016, },
{0x602CF, 0x6023C, 0x701C2, 0x80167, 0xA0126, 0xB00F7, 0xD00D4, 0xF00B9, 0x1100A4, 0x120093, 0x140085, 0x16007A, 0x180070, 0x1A0067, 0x1C0060, 0x1E005A, 0x200054, 0x220050, 0x24004B, 0x260047, 0x280044, 0x2A0041, 0x2C003E, 0x2E003B, 0x300039, 0x320036, 0x340034, 0x360032, 0x380030, 0x3A002F, 0x3C002D, 0x3E002C, 0x40002A, 0x420029, 0x440028, 0x460027, 0x480026, 0x4A0025, 0x4C0024, 0x4E0023, 0x500022, 0x520021, },
{0x802CF, 0x8025F, 0x801FB, 0xA01A9, 0xB0167, 0xC0135, 0xE010D, 0x1000ED, 0x1100D4, 0x1300BF, 0x1500AE, 0x17009F, 0x190093, 0x1B0088, 0x1D007F, 0x1F0077, 0x200070, 0x220069, 0x240064, 0x26005F, 0x28005A, 0x2A0056, 0x2C0052, 0x2E004E, 0x30004B, 0x320048, 0x340045, 0x360043, 0x380041, 0x3A003E, 0x3C003C, 0x3E003A, 0x400039, 0x420037, 0x440035, 0x460034, 0x480032, 0x4A0031, 0x4C0030, 0x4E002E, 0x50002D, 0x52002C, },
{0xA02CF, 0xA0275, 0xA0221, 0xB01D8, 0xC019A, 0xE0167, 0xF013E, 0x11011C, 0x120100, 0x1400E8, 0x1600D4, 0x1800C3, 0x1A00B4, 0x1B00A8, 0x1D009D, 0x1F0093, 0x21008A, 0x230083, 0x25007C, 0x270075, 0x290070, 0x2B006B, 0x2D0066, 0x2F0062, 0x31005E, 0x32005A, 0x340057, 0x360053, 0x380050, 0x3A004E, 0x3C004B, 0x3E0049, 0x400047, 0x420044, 0x440042, 0x460041, 0x48003F, 0x4A003D, 0x4C003B, 0x4E003A, 0x500039, 0x520037, },
{0xC02CF, 0xC0284, 0xC023C, 0xD01FB, 0xE01C2, 0xF0191, 0x100167, 0x120144, 0x140126, 0x15010D, 0x1700F7, 0x1900E4, 0x1A00D4, 0x1C00C6, 0x1E00B9, 0x2000AE, 0x2200A4, 0x24009B, 0x250093, 0x27008C, 0x290085, 0x2B007F, 0x2D007A, 0x2F0074, 0x310070, 0x33006B, 0x350067, 0x370064, 0x390060, 0x3B005D, 0x3D005A, 0x3F0057, 0x410054, 0x430052, 0x450050, 0x47004D, 0x48004B, 0x4A0049, 0x4C0047, 0x4E0045, 0x500044, 0x520042, },
{0xE02CF, 0xE028E, 0xE0250, 0xF0216, 0x1001E2, 0x1101B3, 0x12018B, 0x130167, 0x150149, 0x16012E, 0x180117, 0x1A0103, 0x1B00F2, 0x1D00E2, 0x1F00D4, 0x2100C8, 0x2200BD, 0x2400B3, 0x2600AA, 0x2800A1, 0x2A009A, 0x2C0093, 0x2E008D, 0x300087, 0x320082, 0x33007D, 0x350078, 0x370074, 0x390070, 0x3B006C, 0x3D0069, 0x3F0065, 0x410062, 0x43005F, 0x45005D, 0x47005A, 0x490058, 0x4B0055, 0x4D0053, 0x4F0051, 0x51004F, 0x53004D, },
{0x1002CF, 0x100296, 0x10025F, 0x11022B, 0x1101FB, 0x1201CF, 0x1401A9, 0x150186, 0x160167, 0x18014D, 0x190135, 0x1B0120, 0x1C010D, 0x1E00FC, 0x2000ED, 0x2200E0, 0x2300D4, 0x2500C9, 0x2700BF, 0x2900B6, 0x2B00AE, 0x2C00A6, 0x2E009F, 0x300099, 0x320093, 0x34008D, 0x360088, 0x380084, 0x3A007F, 0x3C007B, 0x3E0077, 0x400073, 0x410070, 0x43006D, 0x450069, 0x470067, 0x490064, 0x4B0061, 0x4D005F, 0x4F005C, 0x51005A, 0x530058, },
{0x1202CF, 0x12029D, 0x12026B, 0x12023C, 0x130210, 0x1401E7, 0x1501C2, 0x1601A1, 0x180182, 0x190167, 0x1A014F, 0x1C013A, 0x1E0126, 0x1F0115, 0x210105, 0x2200F7, 0x2400EA, 0x2600DF, 0x2800D4, 0x2A00CA, 0x2B00C1, 0x2D00B9, 0x2F00B1, 0x3100AA, 0x3300A4, 0x35009E, 0x370098, 0x380093, 0x3A008E, 0x3C0089, 0x3E0085, 0x400081, 0x42007D, 0x44007A, 0x460076, 0x480073, 0x4A0070, 0x4C006D, 0x4E006A, 0x500067, 0x520065, 0x530063, },
{0x1402CF, 0x1402A2, 0x140275, 0x14024A, 0x150221, 0x1601FB, 0x1701D8, 0x1801B8, 0x19019A, 0x1A0180, 0x1C0167, 0x1D0152, 0x1F013E, 0x20012C, 0x22011C, 0x24010D, 0x250100, 0x2700F3, 0x2900E8, 0x2A00DE, 0x2C00D4, 0x2E00CB, 0x3000C3, 0x3200BB, 0x3400B4, 0x3500AE, 0x3700A8, 0x3900A2, 0x3B009D, 0x3D0098, 0x3F0093, 0x41008F, 0x43008A, 0x440086, 0x460083, 0x48007F, 0x4A007C, 0x4C0078, 0x4E0075, 0x500073, 0x520070, 0x54006D, },
{0x1602CF, 0x1602A6, 0x16027D, 0x160255, 0x170230, 0x18020C, 0x1901EB, 0x1A01CC, 0x1B01AF, 0x1C0195, 0x1D017D, 0x1F0167, 0x200154, 0x220141, 0x230131, 0x250122, 0x260114, 0x280107, 0x2A00FB, 0x2B00F0, 0x2D00E6, 0x2F00DD, 0x3100D4, 0x3200CC, 0x3400C4, 0x3600BD, 0x3800B7, 0x3A00B1, 0x3C00AB, 0x3E00A6, 0x3F00A1, 0x41009C, 0x430097, 0x450093, 0x47008F, 0x49008B, 0x4B0087, 0x4D0084, 0x4F0081, 0x51007E, 0x52007B, 0x540078, },
{0x1802CF, 0x1802A9, 0x180284, 0x18025F, 0x19023C, 0x1A021B, 0x1A01FB, 0x1B01DD, 0x1C01C2, 0x1E01A9, 0x1F0191, 0x20017B, 0x210167, 0x230155, 0x240144, 0x260135, 0x280126, 0x290119, 0x2B010D, 0x2C0102, 0x2E00F7, 0x3000ED, 0x3200E4, 0x3300DC, 0x3500D4, 0x3700CD, 0x3900C6, 0x3B00BF, 0x3C00B9, 0x3E00B3, 0x4000AE, 0x4200A9, 0x4400A4, 0x46009F, 0x48009B, 0x4A0097, 0x4B0093, 0x4D008F, 0x4F008C, 0x510088, 0x530085, 0x550082, },
{0x1A02CF, 0x1A02AC, 0x1A028A, 0x1A0268, 0x1B0247, 0x1B0227, 0x1C0209, 0x1D01ED, 0x1E01D3, 0x1F01BA, 0x2001A3, 0x22018E, 0x23017A, 0x240167, 0x260157, 0x270147, 0x290138, 0x2A012B, 0x2C011E, 0x2E0113, 0x2F0108, 0x3100FE, 0x3300F4, 0x3400EB, 0x3600E3, 0x3800DB, 0x3A00D4, 0x3B00CD, 0x3D00C7, 0x3F00C1, 0x4100BB, 0x4300B6, 0x4500B0, 0x4600AC, 0x4800A7, 0x4A00A3, 0x4C009E, 0x4E009A, 0x500097, 0x520093, 0x540090, 0x56008C, },
{0x1C02CF, 0x1C02AF, 0x1C028E, 0x1C026F, 0x1D0250, 0x1D0232, 0x1E0216, 0x1F01FB, 0x2001E2, 0x2101CA, 0x2201B3, 0x23019E, 0x24018B, 0x260178, 0x270167, 0x290158, 0x2A0149, 0x2C013B, 0x2D012E, 0x2F0123, 0x300117, 0x32010D, 0x340103, 0x3500FA, 0x3700F2, 0x3900E9, 0x3B00E2, 0x3C00DB, 0x3E00D4, 0x4000CE, 0x4200C8, 0x4400C2, 0x4500BD, 0x4700B7, 0x4900B3, 0x4B00AE, 0x4D00AA, 0x4F00A5, 0x5000A1, 0x52009D, 0x54009A, 0x560096, },
{0x1E02CF, 0x1E02B1, 0x1E0293, 0x1E0275, 0x1F0258, 0x1F023C, 0x200221, 0x210207, 0x2201EF, 0x2201D8, 0x2401C2, 0x2501AD, 0x26019A, 0x270188, 0x290177, 0x2A0167, 0x2B0159, 0x2D014B, 0x2E013E, 0x300132, 0x320126, 0x33011C, 0x350112, 0x360108, 0x380100, 0x3A00F7, 0x3C00EF, 0x3D00E8, 0x3F00E1, 0x4100DA, 0x4300D4, 0x4400CE, 0x4600C8, 0x4800C3, 0x4A00BE, 0x4C00B9, 0x4E00B4, 0x4F00B0, 0x5100AC, 0x5300A8, 0x5500A4, 0x5700A0, },
{0x2002CF, 0x2002B3, 0x200296, 0x20027B, 0x20025F, 0x210245, 0x22022B, 0x220212, 0x2301FB, 0x2401E5, 0x2501CF, 0x2601BB, 0x2801A9, 0x290197, 0x2A0186, 0x2B0176, 0x2D0167, 0x2E015A, 0x30014D, 0x310140, 0x330135, 0x34012A, 0x360120, 0x380116, 0x39010D, 0x3B0104, 0x3D00FC, 0x3E00F5, 0x4000ED, 0x4200E7, 0x4400E0, 0x4500DA, 0x4700D4, 0x4900CE, 0x4B00C9, 0x4C00C4, 0x4E00BF, 0x5000BB, 0x5200B6, 0x5400B2, 0x5600AE, 0x5800AA, },
{0x2202CF, 0x2202B5, 0x22029A, 0x22027F, 0x220266, 0x23024C, 0x240234, 0x24021C, 0x250206, 0x2601F0, 0x2701DC, 0x2801C8, 0x2901B6, 0x2A01A4, 0x2C0194, 0x2D0184, 0x2E0175, 0x300167, 0x31015A, 0x32014E, 0x340142, 0x360137, 0x37012D, 0x390123, 0x3A011A, 0x3C0111, 0x3E0109, 0x3F0101, 0x4100FA, 0x4300F3, 0x4400EC, 0x4600E5, 0x4800DF, 0x4A00DA, 0x4C00D4, 0x4D00CF, 0x4F00CA, 0x5100C5, 0x5300C0, 0x5500BC, 0x5600B8, 0x5800B4, },
{0x2402CF, 0x2402B6, 0x24029D, 0x240284, 0x24026B, 0x250253, 0x25023C, 0x260225, 0x270210, 0x2801FB, 0x2901E7, 0x2A01D4, 0x2B01C2, 0x2C01B1, 0x2D01A1, 0x2E0191, 0x300182, 0x310175, 0x320167, 0x34015B, 0x35014F, 0x370144, 0x38013A, 0x3A0130, 0x3C0126, 0x3D011E, 0x3F0115, 0x40010D, 0x420105, 0x4400FE, 0x4500F7, 0x4700F1, 0x4900EA, 0x4B00E4, 0x4C00DF, 0x4E00D9, 0x5000D4, 0x5200CF, 0x5400CA, 0x5500C6, 0x5700C1, 0x5900BD, },
{0x2602CF, 0x2602B7, 0x26029F, 0x260288, 0x260270, 0x27025A, 0x270243, 0x28022E, 0x290219, 0x2A0205, 0x2A01F1, 0x2B01DF, 0x2C01CD, 0x2E01BC, 0x2F01AC, 0x30019D, 0x31018F, 0x320181, 0x340174, 0x350167, 0x37015C, 0x380151, 0x3A0146, 0x3B013C, 0x3D0132, 0x3E0129, 0x400121, 0x420119, 0x430111, 0x450109, 0x470102, 0x4800FC, 0x4A00F5, 0x4C00EF, 0x4D00E9, 0x4F00E3, 0x5100DE, 0x5300D9, 0x5400D4, 0x5600CF, 0x5800CB, 0x5A00C6, },
{0x2802CF, 0x2802B9, 0x2802A2, 0x28028B, 0x280275, 0x29025F, 0x29024A, 0x2A0235, 0x2B0221, 0x2B020E, 0x2C01FB, 0x2D01E9, 0x2E01D8, 0x2F01C7, 0x3001B8, 0x3201A9, 0x33019A, 0x34018D, 0x350180, 0x370173, 0x380167, 0x3A015C, 0x3B0152, 0x3C0148, 0x3E013E, 0x400135, 0x41012C, 0x430124, 0x44011C, 0x460114, 0x48010D, 0x490106, 0x4B0100, 0x4D00F9, 0x4E00F3, 0x5000ED, 0x5200E8, 0x5400E3, 0x5500DE, 0x5700D9, 0x5900D4, 0x5B00D0, },
{0x2A02CF, 0x2A02BA, 0x2A02A4, 0x2A028E, 0x2A0279, 0x2B0264, 0x2B0250, 0x2C023C, 0x2C0229, 0x2D0216, 0x2E0204, 0x2F01F2, 0x3001E2, 0x3101D1, 0x3201C2, 0x3301B3, 0x3401A5, 0x360198, 0x37018B, 0x38017E, 0x3A0173, 0x3B0167, 0x3C015D, 0x3E0153, 0x3F0149, 0x410140, 0x420137, 0x44012E, 0x460126, 0x47011F, 0x490117, 0x4A0110, 0x4C010A, 0x4E0103, 0x4F00FD, 0x5100F7, 0x5300F2, 0x5500EC, 0x5600E7, 0x5800E2, 0x5A00DD, 0x5C00D8, },
{0x2C02CF, 0x2C02BB, 0x2C02A6, 0x2C0291, 0x2C027D, 0x2D0269, 0x2D0255, 0x2E0242, 0x2E0230, 0x2F021E, 0x30020C, 0x3101FB, 0x3201EB, 0x3301DB, 0x3401CC, 0x3501BD, 0x3601AF, 0x3701A2, 0x380195, 0x3A0189, 0x3B017D, 0x3C0172, 0x3E0167, 0x3F015D, 0x410154, 0x42014A, 0x440141, 0x450139, 0x470131, 0x480129, 0x4A0122, 0x4C011A, 0x4D0114, 0x4F010D, 0x500107, 0x520101, 0x5400FB, 0x5600F5, 0x5700F0, 0x5900EB, 0x5B00E6, 0x5D00E1, },
{0x2E02CF, 0x2E02BC, 0x2E02A8, 0x2E0294, 0x2E0281, 0x2F026D, 0x2F025B, 0x300248, 0x300236, 0x310225, 0x320214, 0x320203, 0x3301F3, 0x3401E4, 0x3501D5, 0x3601C7, 0x3801B9, 0x3901AC, 0x3A019F, 0x3B0193, 0x3C0187, 0x3E017C, 0x3F0172, 0x410167, 0x42015E, 0x430154, 0x45014B, 0x460143, 0x48013B, 0x4A0133, 0x4B012B, 0x4D0124, 0x4E011D, 0x500117, 0x520110, 0x53010A, 0x550104, 0x5700FE, 0x5800F9, 0x5A00F4, 0x5C00EF, 0x5E00EA, },
{0x3002CF, 0x3002BC, 0x3002A9, 0x300296, 0x300284, 0x310271, 0x31025F, 0x32024D, 0x32023C, 0x33022B, 0x34021B, 0x34020B, 0x3501FB, 0x3601EC, 0x3701DD, 0x3801CF, 0x3901C2, 0x3A01B5, 0x3C01A9, 0x3D019D, 0x3E0191, 0x3F0186, 0x41017B, 0x420171, 0x430167, 0x45015E, 0x460155, 0x48014D, 0x490144, 0x4B013C, 0x4C0135, 0x4E012D, 0x500126, 0x510120, 0x530119, 0x540113, 0x56010D, 0x580107, 0x590102, 0x5B00FC, 0x5D00F7, 0x5F00F2, },
{0x3202CF, 0x3202BD, 0x3202AB, 0x320299, 0x320287, 0x320275, 0x330264, 0x330252, 0x340242, 0x350231, 0x350221, 0x360212, 0x370202, 0x3801F4, 0x3901E6, 0x3A01D8, 0x3B01CB, 0x3C01BE, 0x3D01B1, 0x3E01A6, 0x40019A, 0x41018F, 0x420185, 0x43017B, 0x450171, 0x460167, 0x48015F, 0x490156, 0x4B014E, 0x4C0146, 0x4E013E, 0x4F0137, 0x51012F, 0x520129, 0x540122, 0x56011C, 0x570116, 0x590110, 0x5A010A, 0x5C0105, 0x5E0100, 0x6000FA, },
{0x3402CF, 0x3402BE, 0x3402AC, 0x34029B, 0x34028A, 0x340278, 0x350268, 0x350257, 0x360247, 0x370237, 0x370227, 0x380218, 0x390209, 0x3A01FB, 0x3B01ED, 0x3C01E0, 0x3D01D3, 0x3E01C6, 0x3F01BA, 0x4001AE, 0x4101A3, 0x420198, 0x44018E, 0x450184, 0x46017A, 0x480170, 0x490167, 0x4A015F, 0x4C0157, 0x4D014F, 0x4F0147, 0x50013F, 0x520138, 0x540131, 0x55012B, 0x570124, 0x58011E, 0x5A0118, 0x5C0113, 0x5D010D, 0x5F0108, 0x610103, },
{0x3602CF, 0x3602BF, 0x3602AE, 0x36029D, 0x36028C, 0x36027C, 0x37026B, 0x37025B, 0x38024B, 0x38023C, 0x39022D, 0x3A021E, 0x3B0210, 0x3B0202, 0x3C01F4, 0x3D01E7, 0x3E01DA, 0x3F01CE, 0x4001C2, 0x4201B6, 0x4301AB, 0x4401A1, 0x450196, 0x46018C, 0x480182, 0x490179, 0x4A0170, 0x4C0167, 0x4D015F, 0x4F0157, 0x50014F, 0x520148, 0x530141, 0x55013A, 0x560133, 0x58012D, 0x5A0126, 0x5B0120, 0x5D011B, 0x5E0115, 0x600110, 0x62010A, },
{0x3802CF, 0x3802BF, 0x3802AF, 0x38029F, 0x38028E, 0x38027F, 0x39026F, 0x39025F, 0x3A0250, 0x3A0241, 0x3B0232, 0x3C0224, 0x3C0216, 0x3D0208, 0x3E01FB, 0x3F01EE, 0x4001E2, 0x4101D5, 0x4201CA, 0x4301BE, 0x4401B3, 0x4601A9, 0x47019E, 0x480194, 0x49018B, 0x4B0181, 0x4C0178, 0x4D0170, 0x4F0167, 0x50015F, 0x520158, 0x530150, 0x550149, 0x560142, 0x58013B, 0x590135, 0x5B012E, 0x5C0128, 0x5E0123, 0x60011D, 0x610117, 0x630112, },
{0x3A02CF, 0x3A02C0, 0x3A02B0, 0x3A02A0, 0x3A0291, 0x3A0281, 0x3B0272, 0x3B0263, 0x3C0254, 0x3C0246, 0x3D0237, 0x3E0229, 0x3E021C, 0x3F020E, 0x400201, 0x4101F5, 0x4201E8, 0x4301DC, 0x4401D1, 0x4501C6, 0x4601BB, 0x4701B0, 0x4801A6, 0x4A019C, 0x4B0193, 0x4C0189, 0x4D0180, 0x4F0178, 0x500170, 0x520167, 0x530160, 0x540158, 0x560151, 0x57014A, 0x590143, 0x5A013D, 0x5C0136, 0x5E0130, 0x5F012A, 0x610125, 0x62011F, 0x64011A, },
{0x3C02CF, 0x3C02C0, 0x3C02B1, 0x3C02A2, 0x3C0293, 0x3C0284, 0x3D0275, 0x3D0266, 0x3E0258, 0x3E024A, 0x3F023C, 0x3F022E, 0x400221, 0x410214, 0x420207, 0x4301FB, 0x4401EF, 0x4401E3, 0x4501D8, 0x4701CD, 0x4801C2, 0x4901B8, 0x4A01AD, 0x4B01A4, 0x4C019A, 0x4E0191, 0x4F0188, 0x500180, 0x520177, 0x53016F, 0x540167, 0x560160, 0x570159, 0x590152, 0x5A014B, 0x5C0144, 0x5D013E, 0x5F0138, 0x600132, 0x62012C, 0x640126, 0x650121, },
{0x3E02CF, 0x3E02C1, 0x3E02B2, 0x3E02A3, 0x3E0295, 0x3E0286, 0x3F0278, 0x3F026A, 0x40025C, 0x40024E, 0x410240, 0x410233, 0x420226, 0x430219, 0x44020D, 0x440201, 0x4501F5, 0x4601EA, 0x4701DE, 0x4801D3, 0x4901C9, 0x4A01BF, 0x4C01B5, 0x4D01AB, 0x4E01A2, 0x4F0198, 0x500190, 0x520187, 0x53017F, 0x540177, 0x56016F, 0x570167, 0x590160, 0x5A0159, 0x5C0152, 0x5D014C, 0x5F0145, 0x60013F, 0x620139, 0x630133, 0x65012E, 0x660128, },
{0x4002CF, 0x4002C1, 0x4002B3, 0x4002A5, 0x400296, 0x400288, 0x41027B, 0x41026D, 0x41025F, 0x420252, 0x430245, 0x430238, 0x44022B, 0x45021F, 0x450212, 0x460207, 0x4701FB, 0x4801F0, 0x4901E5, 0x4A01DA, 0x4B01CF, 0x4C01C5, 0x4D01BB, 0x4E01B2, 0x5001A9, 0x5101A0, 0x520197, 0x53018E, 0x550186, 0x56017E, 0x570176, 0x59016F, 0x5A0167, 0x5B0160, 0x5D015A, 0x5E0153, 0x60014D, 0x610146, 0x630140, 0x64013A, 0x660135, 0x68012F, },
{0x4202CF, 0x4202C2, 0x4202B4, 0x4202A6, 0x420298, 0x42028B, 0x43027D, 0x430270, 0x430262, 0x440255, 0x440249, 0x45023C, 0x460230, 0x460223, 0x470218, 0x48020C, 0x490201, 0x4A01F5, 0x4B01EB, 0x4C01E0, 0x4D01D6, 0x4E01CC, 0x4F01C2, 0x5001B8, 0x5101AF, 0x5201A6, 0x54019E, 0x550195, 0x56018D, 0x570185, 0x59017D, 0x5A0176, 0x5B016F, 0x5D0167, 0x5E0161, 0x60015A, 0x610154, 0x63014D, 0x640147, 0x660141, 0x67013C, 0x690136, },
{0x4402CF, 0x4402C2, 0x4402B5, 0x4402A7, 0x44029A, 0x44028D, 0x45027F, 0x450272, 0x450266, 0x460259, 0x46024C, 0x470240, 0x480234, 0x480228, 0x49021C, 0x4A0211, 0x4B0206, 0x4C01FB, 0x4C01F0, 0x4D01E6, 0x4E01DC, 0x4F01D2, 0x5001C8, 0x5201BF, 0x5301B6, 0x5401AD, 0x5501A4, 0x56019C, 0x580194, 0x59018C, 0x5A0184, 0x5C017D, 0x5D0175, 0x5E016E, 0x600167, 0x610161, 0x63015A, 0x640154, 0x65014E, 0x670148, 0x680142, 0x6A013D, },
{0x4602CF, 0x4602C2, 0x4602B5, 0x4602A8, 0x46029B, 0x46028E, 0x470282, 0x470275, 0x470268, 0x48025C, 0x480250, 0x490244, 0x4A0238, 0x4A022C, 0x4B0221, 0x4C0216, 0x4C020B, 0x4D0200, 0x4E01F6, 0x4F01EC, 0x5001E2, 0x5101D8, 0x5201CE, 0x5301C5, 0x5401BC, 0x5601B3, 0x5701AB, 0x5801A2, 0x59019A, 0x5A0192, 0x5C018B, 0x5D0183, 0x5E017C, 0x600175, 0x61016E, 0x620167, 0x640161, 0x65015B, 0x670155, 0x68014F, 0x6A0149, 0x6B0143, },
{0x4802CF, 0x4802C3, 0x4802B6, 0x4802A9, 0x48029D, 0x480290, 0x480284, 0x490277, 0x49026B, 0x4A025F, 0x4A0253, 0x4B0248, 0x4B023C, 0x4C0231, 0x4D0225, 0x4E021B, 0x4E0210, 0x4F0205, 0x5001FB, 0x5101F1, 0x5201E7, 0x5301DD, 0x5401D4, 0x5501CB, 0x5601C2, 0x5701B9, 0x5801B1, 0x5A01A9, 0x5B01A1, 0x5C0199, 0x5D0191, 0x5F018A, 0x600182, 0x61017B, 0x630175, 0x64016E, 0x650167, 0x670161, 0x68015B, 0x6A0155, 0x6B014F, 0x6D014A, },
{0x4A02CF, 0x4A02C3, 0x4A02B7, 0x4A02AA, 0x4A029E, 0x4A0292, 0x4A0286, 0x4B027A, 0x4B026E, 0x4C0262, 0x4C0257, 0x4D024B, 0x4D0240, 0x4E0235, 0x4F022A, 0x4F021F, 0x500214, 0x51020A, 0x520200, 0x5301F6, 0x5401EC, 0x5501E3, 0x5601DA, 0x5701D1, 0x5801C8, 0x5901BF, 0x5A01B7, 0x5B01AF, 0x5C01A7, 0x5E019F, 0x5F0197, 0x600190, 0x610189, 0x630182, 0x64017B, 0x650174, 0x67016E, 0x680167, 0x6A0161, 0x6B015B, 0x6C0156, 0x6E0150, },
{0x4C02CF, 0x4C02C3, 0x4C02B7, 0x4C02AB, 0x4C029F, 0x4C0294, 0x4C0288, 0x4D027C, 0x4D0270, 0x4E0265, 0x4E025A, 0x4F024E, 0x4F0243, 0x500238, 0x50022E, 0x510223, 0x520219, 0x53020F, 0x540205, 0x5401FB, 0x5501F1, 0x5601E8, 0x5701DF, 0x5801D6, 0x5901CD, 0x5A01C5, 0x5C01BC, 0x5D01B4, 0x5E01AC, 0x5F01A5, 0x60019D, 0x620196, 0x63018F, 0x640188, 0x650181, 0x67017A, 0x680174, 0x6A016E, 0x6B0167, 0x6C0162, 0x6E015C, 0x6F0156, },
{0x4E02CF, 0x4E02C4, 0x4E02B8, 0x4E02AC, 0x4E02A1, 0x4E0295, 0x4E028A, 0x4F027E, 0x4F0273, 0x500268, 0x50025C, 0x510251, 0x510247, 0x52023C, 0x520232, 0x530227, 0x54021D, 0x550213, 0x550209, 0x560200, 0x5701F6, 0x5801ED, 0x5901E4, 0x5A01DB, 0x5B01D3, 0x5C01CA, 0x5D01C2, 0x5E01BA, 0x6001B2, 0x6101AA, 0x6201A3, 0x63019C, 0x640195, 0x66018E, 0x670187, 0x680180, 0x6A017A, 0x6B0174, 0x6C016D, 0x6E0167, 0x6F0162, 0x71015C, },
{0x5002CF, 0x5002C4, 0x5002B9, 0x5002AD, 0x5002A2, 0x500296, 0x50028B, 0x510280, 0x510275, 0x52026A, 0x52025F, 0x520254, 0x53024A, 0x54023F, 0x540235, 0x55022B, 0x560221, 0x560217, 0x57020E, 0x580204, 0x5901FB, 0x5A01F2, 0x5B01E9, 0x5C01E0, 0x5D01D8, 0x5E01CF, 0x5F01C7, 0x6001BF, 0x6101B8, 0x6201B0, 0x6401A9, 0x6501A1, 0x66019A, 0x670193, 0x68018D, 0x6A0186, 0x6B0180, 0x6C0179, 0x6E0173, 0x6F016D, 0x710167, 0x720162, },
{0x5202CF, 0x5202C4, 0x5202B9, 0x5202AE, 0x5202A3, 0x520298, 0x52028D, 0x530282, 0x530277, 0x53026C, 0x540262, 0x540257, 0x55024D, 0x560243, 0x560239, 0x57022F, 0x580225, 0x58021B, 0x590212, 0x5A0209, 0x5B01FF, 0x5C01F7, 0x5D01EE, 0x5E01E5, 0x5F01DD, 0x6001D5, 0x6101CC, 0x6201C5, 0x6301BD, 0x6401B5, 0x6501AE, 0x6601A7, 0x6801A0, 0x690199, 0x6A0192, 0x6B018C, 0x6D0185, 0x6E017F, 0x6F0179, 0x710173, 0x72016D, 0x730167, },
};

static uint32_t _cledMatrixAngle(float x, float y, float cx, float cy)
{
    double angle    = (atan2(x - cx, y - cy)) * 180 / 3.14159265359;
    double distance = sqrt(pow(cx - x, 2) + pow(cy - y, 2));

    struct cledMatrixPixel piont;

    piont.angle = angle*8.0f;
    piont.radius = distance*2.0f;

    return piont.pixel;
}
/*************************************************************************************************
* 为节省空间占用,仅计算 0-90°范围,其它角度根据象限间的关系重新计算
* 为节保留 精度并加快运算速度,将处理后的结果保存为整型，精度为 1/64
**************************************************************************************************/
void cledMatrixAngle(const uint16_t cols, const uint16_t rows)
{
    float cx = 0;//(cols - 1) * 0.5;
    float cy = 0;//(rows - 1) * 0.5;
    struct cledMatrixPixel matrix[128][128];
    for (uint32_t col_id = 0; col_id < cols; col_id++)
    {
        for (uint32_t row_id = 0; row_id < rows; row_id++)
        {
            matrix[col_id][row_id].pixel = _cledMatrixAngle(col_id, row_id, cx, cy);
        }
    }
    //printf("const uint16_t RotateMatrix[%d][%d] = {\r\n", MATRIX_SIZE, MATRIX_SIZE);
    //printf("const uint16_t RotateMatrixAngle[MATRIX_SIZE][MATRIX_SIZE] = {\r\n");
    //printf("const uint32_t RotateMatrixAngle[%d][%d] = {\r\n", cols, rows);
    printf("static const uint32_t RotateMatrixAngle[MATRIX_ANGLE_SIZE][MATRIX_ANGLE_SIZE] = {\r\n");
    for(int y=0; y<rows; y++)
    {
        printf("{");
        for(int x=0; x<cols; x++)
        {
            //printf("%4d, ",  (int)matrix[y][x].angle);
            printf("0x%08X, ",  matrix[y][x].pixel);
        }
        printf("},\r\n");
    }
    printf("};\r\n");
    fflush(stdout);
}
void cledMatrixAngle2(void)
{
    cledMatrixAngle(MATRIX_ANGLE_SIZE, MATRIX_ANGLE_SIZE);
}
#if 1
uint32_t cledMatrixAngleGet(const int16_t x, const int16_t y)
{
    struct cledMatrixPixel piont = {0};
    if((x>=MATRIX_ANGLE_SIZE) || (x<=-MATRIX_ANGLE_SIZE)) return 0;
    if((y>=MATRIX_ANGLE_SIZE) || (y<=-MATRIX_ANGLE_SIZE)) return 0;
    if((x>=0) && (y>=0)) // 第一象限
    {
        return RotateMatrixAngle[y][x];
    }
    if((x<0) && (y>=0)) // 第二象限
    {
        piont.pixel = RotateMatrixAngle[y][-x];
        piont.angle = 180*8 - piont.angle;
    }
    if((x<0) && (y<0)) // 第三象限
    {
        piont.pixel = RotateMatrixAngle[-y][-x];
        piont.angle = 180*8 + piont.angle;
    }
    if((x>=0) && (y<0)) // 第四象限
    {
        piont.pixel = RotateMatrixAngle[-y][x];
        piont.angle = 360*8 - piont.angle;
    }
    return piont.pixel;
}
#else
uint32_t cledMatrixAngleGet(const int16_t x, const int16_t y)
{
    float cx = (MATRIX_ANGLE_SIZE - 1) * 0.5;
    float cy = (MATRIX_ANGLE_SIZE - 1) * 0.5;
    return RotateMatrixAngle[(int)(x + cx)][(int)(y + cy)];
}
#endif
